﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VDataAdapter.Utilities
{
    class Utils
    {
        /// <summary>
        /// Convert IDictionary[T1,T3]  to Dictionary [T1,T2] 
        /// </summary>
        /// <typeparam name="T1"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <typeparam name="T3"></typeparam>
        /// <param name="d"></param>
        /// <returns></returns>
        public static Dictionary<T1, T3> ConvertDictionary<T1, T2, T3>(IDictionary<T1, T2> d)
        {
            Dictionary<T1, T3> result = new Dictionary<T1, T3>();

            foreach (KeyValuePair<T1, T2> key in d)
            {
                Object obj = (Object)key.Value;
                T3 objConvert = (T3)obj;
                result.Add(key.Key, objConvert);
            }
            return result;
        } 
    }
}
